<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div >
<div class="w2">會期維護 » 決議內容 </div>
	<c:forEach items="${motionForm.motions}" var="motion" varStatus="status">
	<div id="block${status.index}" style="margin:50px 5px 50px 5px" >
	<form:form modelAttribute="motionForm" id="motionForm${status.index}">
		<form:hidden id="motionSeq${status.index}" path="motions[${status.index}].motionSeq"  />
		<form:hidden id="sessionNo${status.index}" path="motions[${status.index}].sessionNo" value="${motion.session.sessionNo}"  />
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="8%" >會期：<b><font color="#0000CD">${motion.session.sessionNo }</font></b></td>
			<td width="8%" align="left">案別：<font color="#0000CD">${motion.typeNo }  ${motion.type }</font></td>
			
			<td width="5%" align="left">臨時：<font color="#FF0000">${motion.provisional?"✔":"" }</font></td>
			<td width="5%" align="left">案次：<font color="#0000CD">${motion.motionOrder}</font></td>
			<td width="10%" align="left">提案單位：<font color="#0000CD">${motion.unitCode }  ${motion.unitName }</font></td>
			<td width="20%" align="left">
				分機：<font color="#0000CD">${motion.telNo } </font> 
				承辦：<font color="#0000CD">${motion.inCharge } </font> 
				科長：<font color="#0000CD">${motion.sectionChief }</font>
			</td>
		</tr>  
	</table>
	<br/>
	<table width="100%" border="0" >
		<tr>
			<td valign="top" width="5%">案由：<b><font color="#0000CD">${motion.cause }</font></b></td>
		</tr>
	</table>
	<br/>
	<table width="100%" border="0" >
		<tr>
			<td valign="top" width="5%" rowspan="2">決議：</td>
			<td width="35%"  rowspan="2"><form:textarea id="resolution${status.index}" path="motions[${status.index}].resolution" name="resolution" cols="60" rows="10" ></form:textarea></td>
			<td align="right" valign="top" width="8%">常用決議：</td>
			<td width="45%">
				<form:select path="motions[${status.index}].discipline" id="cr${status.index}" style="width:350px" onchange="javascript:select(${status.index});">
					<form:option value="" label=""/>
	            	<form:options items="${codeResolution}" itemValue="name" itemLabel="name"/>
	        	</form:select>
	        </td>
		</tr>
		<tr>
			<td align="right" valign="top" width="8%">附帶決議：</td>
			<td width="45%" valign="top"><form:textarea  id="subResolution${status.index}" path="motions[${status.index}].subResolution" name="subResolution" cols="60" rows="8" ></form:textarea></td>
		</tr>
	</table>
	<div align="right">
		<font id="hid${status.index}" color="red" size="4">更新成功</font>
		<a href="#do" class="easyui-linkbutton" onClick="save(${status.index});">存檔</a>
		<a href="#do" class="easyui-linkbutton" onClick="del($('#block${status.index}'),${motion.motionSeq });">刪除</a>
		<a href="${appPath}/report/${motion.motionSeq}/report8single.htm" class="easyui-linkbutton" ">匯出</a>
	</div>
	
	<hr size="2" style="margin:20px"/>
	</form:form>
	</div>
	</c:forEach>

</div>
<script type="text/javascript">
$().ready(function() {
	$( "font[id*='hid']" ).hide();
});	
function runEffect(id) {
    $( "#hid"+id ).show( "highlight", {}, 500, function(){
    	setTimeout(function() {
   		   $( "#hid"+id+":visible" ).fadeOut();
   		 }, 1500 );
    } );
};
function save( num ){
	var o = {};
	$.each($("#motionForm"+num).serializeArray(), function(i, v) { 
		var dot = v.name.lastIndexOf(".");
		var name = v.name.substr(dot+1);
		o[name] = v.value; 
	});
	$.post( "${appPath}/motion/decide.json",o, 
		function( data ) {
			if (eval(data)) {
				runEffect(num);
			} else{   
				alert("更新失敗!");
			}
	});
}
function select(num){
	var val = $("#cr"+num).val();	
	$("#resolution"+num).append(val);	
	$("#cr"+num).val("");
}
</script>